package com.ruoyi.web.controller.storage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basicData.ruleSetting.domain.AccessoryDataVo;
import com.ruoyi.storage.bicycle.domain.vo.BicycleFittingVo;
import com.ruoyi.storage.bicycle.domain.vo.BicycleVo;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.storage.bicycle.domain.Bicycle;
import com.ruoyi.storage.bicycle.service.IBicycleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ControlAcquisitionController
 * 
 * @author zzx
 * @date 2024-01-29
 */
@RestController
@RequestMapping("/system/bicycle")
public class BicycleController extends BaseController
{
    @Autowired
    private IBicycleService bicycleService;

    /**
     * 查询ControlAcquisition列表
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bicycle bicycle)
    {
        startPage();
        List<Bicycle> list = bicycleService.selectBicycleList(bicycle);
        return getDataTable(list);
    }
    /**
     * 查询四码采集列表
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:list')")
    @GetMapping("/listorder")
    public TableDataInfo listorder(Bicycle bicycle)
    {
        startPage();
        List<Bicycle> list = bicycleService.selectBicycleListorder(bicycle);
        return getDataTable(list);
    }
    /**
     * 导出ControlAcquisition列表
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:export')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BicycleFittingVo bicycle)
    {
        List<Bicycle> list = bicycleService.selectBicycleList(bicycle);
        ExcelUtil<Bicycle> util = new ExcelUtil<Bicycle>(Bicycle.class);
        util.exportExcel(response, list, "ControlAcquisition数据");
    }

    /**
     * 获取ControlAcquisition详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:query')")
    @GetMapping(value = "/{bicycleId}")
    public AjaxResult getInfo(@PathVariable("bicycleId") String bicycleId)
    {
        return success(bicycleService.selectBicycleByBicycleId(bicycleId));
    }

    /**
     * 新增ControlAcquisition
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:add')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bicycle bicycle)
    {
        return toAjax(bicycleService.insertBicycle(bicycle));
    }

    /**
     * 修改ControlAcquisition
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:edit')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BicycleVo bicycleVo)
    {
        return bicycleService.updateBicycle(bicycleVo);
    }

    /**
     * 删除ControlAcquisition
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:remove')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bicycleIds}")
    public AjaxResult remove(@PathVariable String[] bicycleIds)
    {
        return toAjax(bicycleService.deleteBicycleByBicycleIds(bicycleIds));
    }
    /**
     * 查询订单是否已结案
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:query')")
    @GetMapping("/getTicketsclose/{orderId}")
    public AjaxResult select(@PathVariable("orderId") String orderId)
    {
        return bicycleService.selectTicketsclose(orderId);
    }
    /**
     * 审核状态
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:edit')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.UPDATE)
    @PutMapping("/audit/{bicycleIds}")
    public AjaxResult editAudit(@PathVariable String[] bicycleIds)
    {
        return bicycleService.updateBicycleAudit(bicycleIds);
    }
    /**
     * 反审核状态
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:edit')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.UPDATE)
    @PutMapping("/unaudit/{bicycleIds}")
    public AjaxResult editUnAudit(@PathVariable String[] bicycleIds)
    {
        return bicycleService.updateBicycleUnAudit(bicycleIds);
    }
    /**
     * 四码采集审核状态
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:edit')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.UPDATE)
    @PutMapping("/order/audit/{bicycleIds}")
    public AjaxResult editOrderAudit(@PathVariable String[] bicycleIds)
    {
        return bicycleService.updateBicycleOrderAudit(bicycleIds);
    }
    /**
     * 四码采集反审核状态
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:edit')")
    @Log(title = "ControlAcquisition", businessType = BusinessType.UPDATE)
    @PutMapping("/order/unaudit/{bicycleIds}")
    public AjaxResult editOrderUnAudit(@PathVariable String[] bicycleIds)
    {
        return bicycleService.updateBicycleOrderUnAudit(bicycleIds);
    }
    /**
     * 打印车辆ID
     */
    @PreAuthorize("@ss.hasPermi('system:bicycle:edit')")
    @Log(title = "ControlAcquisition")
    @PutMapping("/print/{bicycleIds}")
    public AjaxResult print(@PathVariable String[] bicycleIds)
    {
        return bicycleService.updateStatusById(bicycleIds);
    }
    /**
     * 校验配件和供应商
     */
    @GetMapping("/fitting")
    public AjaxResult fitting( AccessoryDataVo accessoryDataVo)
    {
        return bicycleService.selectFitting(accessoryDataVo);
    }
    /**
     * 查询所有配件
     */
    @GetMapping("/fittings")
    public AjaxResult fittings()
    {
        return bicycleService.selectFittings();
    }
}
